package com.example.lzl.bottom_menu;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by lzl on 2016/11/4.
 */

public class MyListFragment extends ListFragment {
    private String TAG=MyListFragment.class.getName();
    private ListView list;
    private SimpleAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //return super.onCreateView(inflater, container, savedInstanceState);
        View view=inflater.inflate(R.layout.tab01_content,container,false);
        list= (ListView) view.findViewById(R.id.list_news);
        Log.i(TAG,"----onCreateView");
        return view;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i(TAG,"---onCreate");
        String lists[]={"news1","news2","news3","news4"};
        adapter=new SimpleAdapter(getActivity(),getData(lists),R.layout.support_simple_spinner_dropdown_item,new String[]{"title"},new int[]{R.id.list_title});
    }

    private List<? extends Map<String,?>> getData(String[] lists) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < lists.length; i++) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("title", lists[i]);
            list.add(map);
        }
        return list;
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        HashMap<String, Object> view= (HashMap<String, Object>) l.getItemAtPosition(position);
        Intent i=new Intent();
    }
}
